package com.example.demo.service.impl;

import com.example.demo.dao.CourseDao;
import com.example.demo.entity.CourseBean;
import com.example.demo.service.CourseService;
import com.example.demo.util.PageEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    private CourseDao courseDao;

    @Override
    public Integer add(CourseBean courseBean) {
        return courseDao.add(courseBean);
    }

    @Override
    public Integer update(CourseBean courseBean) {
        return courseDao.update(courseBean);
    }

    @Override
    public Integer delete(Integer id) {
        return courseDao.delete(id);
    }

    @Override
    public CourseBean one(Integer id) {
        return courseDao.getOneById(id);
    }

    @Override
    public PageEntity list(Integer pageNo, Integer pageSize, String name, String sortOrder) {
        Integer count = courseDao.count(name);
        List<CourseBean> list = courseDao.list(name, sortOrder);
        return new PageEntity<>(list, count);
    }
} 